#ifndef __SPARSE_MATRIX_H
#define __SPARSE_MATRIX_H
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef double elem;

typedef struct cell_t {
  struct cell_t *row_next; /* pointer to the next element in the row.  */
  struct cell_t *col_next; /* pointer to the next element in the column.  */
  int    rowind;           /* index in row */
  int    colind;           /* index in column */
  elem   value;            /* value of the elem.   */
} cell_t; /* matrix cell data type */

typedef struct  {
  int     n;           /* size */
  cell_t **rows;       /* array of row lists.  */
  cell_t **cols;       /* array of col lists.  */
} sparse_matrix_lst; /* sparse matrix representation */


/* Memory allocation for sparse matrix */
sparse_matrix_lst* allocate_sparse_matrix_lst(int n);

/* Releasing the main vectors of the sparse matrix and all their cells */
void free_sparse_matrix_lst(sparse_matrix_lst* matrix);

/* Multiplication of sparse matrix by vector */
void mult_sparse_list(const sparse_matrix_lst *A, const elem* v, elem* result);

#endif /* __SPARSE_MATRIX_H*/
